import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios'
import {
    Pagination,
    Dialog,
    Dropdown,
    DropdownMenu,
    DropdownItem,
    Menu,
    Submenu,
    MenuItem,
    MenuItemGroup,
    Input,
    InputNumber,
    Table,
    TableColumn,
    Button,
    Breadcrumb,
    BreadcrumbItem,
    Form,
    FormItem,
    Icon,
    Row,
    Col,
    Loading,
    Message,
    Checkbox
} from 'element-ui'
//import 'element-ui/lib/theme-chalk/index.css';    // 默认主题
import '../static/css/theme-green/index.css' // 浅绿色主题
import '../static/css/icon.css'
// import 'babel-polyfill'
import httpRequest from '@/utils/httpRequest'
import VueCookie from 'vue-cookie'
import '../static/icon-font/iconfont.css'

import promise from 'es6-promise' //ie支持axios
promise.polyfill()

Vue.use(Pagination)
Vue.use(Dialog)
Vue.use(Dropdown)
Vue.use(DropdownMenu)
Vue.use(DropdownItem)
Vue.use(Menu)
Vue.use(Submenu)
Vue.use(MenuItem)
Vue.use(MenuItemGroup)
Vue.use(Input)
Vue.use(InputNumber)
Vue.use(Button)
Vue.use(Table)
Vue.use(TableColumn)
Vue.use(Breadcrumb)
Vue.use(BreadcrumbItem)
Vue.use(Form)
Vue.use(FormItem)
Vue.use(Icon)
Vue.use(Row)
Vue.use(Col)
Vue.use(Checkbox)

Vue.prototype.$ELEMENT = { size: 'small', zIndex: 3000 }
Vue.use(Loading.directive)
Vue.prototype.$loading = Loading.service
Vue.prototype.$message = Message

Vue.use(VueCookie)
Vue.prototype.$http = axios
Vue.prototype.$http = httpRequest

//使用钩子函数对路由进行权限跳转
router.beforeEach((to, from, next) => {
    const role = Vue.cookie.get('token')
    if (!role && to.path !== '/login') {
        next('/login')
    } else {
        //简单的判断IE10及以下不进入富文本编辑器，该组件不兼容
        next()
    }
})

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')
